package _08作业.t3;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

public class T3Server {
    public static void main(String[] args) throws IOException {
        System.out.println("服务端启动");
        ServerSocket serverSocket = new ServerSocket(9999);
        Socket socket = serverSocket.accept();
        while (true){


                        InputStream sis = socket.getInputStream();
                        InputStreamReader isr = new InputStreamReader(sis);
                        BufferedReader br = new BufferedReader(isr);
                        String line = br.readLine();
                        System.out.println("客户端发来消息："+line);

                        Scanner scanner = new Scanner(System.in);
                        System.out.print("请输入信息：");
                        String s = scanner.nextLine();
                        if (s.equals("exit")) {
                            break;
                        }
                        OutputStream sos = socket.getOutputStream();
                        PrintStream ps = new PrintStream(sos);
                        ps.println(s);




        }
    }
}
